package com.onlinelibrary.service.impl;

import com.onlinelibrary.mapper.BookTypeMapper;
import com.onlinelibrary.pojo.BookType;
import com.onlinelibrary.result.Result;
import com.onlinelibrary.service.BookTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
public class BookTypeServiceImpl01 implements BookTypeService {

    private final BookTypeMapper bookTypeMapper;


    @Override
    public Result list() {
        List<BookType> list = bookTypeMapper.list();
        return new Result(10000, "获取成功！", list);
    }

    @Override
    public Result deleteType(BookType bookType) {
        Integer i=bookTypeMapper.deleteType(bookType);
        if (i>0){
            return new Result(10000,"删除成功！");
        }else {
            return new Result(1,"删除失败！");
        }
    }

    @Override
    public Result addType(BookType bookType) {
        Integer result = bookTypeMapper.addType(bookType);
        if (result > 0) {
            return new Result(10000, "添加成功！");
        } else {
            return new Result(1, "添加失败");
        }
    }


}
